﻿using AutoMapper;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Process.API.Application.Command.Action.ProductionOrders;
using Process.API.Application.Command.Show;
using Process.Domain;
using Process.ErrorCode;

namespace Process.API.Controllers
{
    /// <summary>
    /// 生产工单
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionOrdersController : ControllerBase
    {
        IMediator mediator;

        public ProductionOrdersController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 生产工单显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<APIPaging<List<ProductionOrders>>>> ProductionOrdersCommand([FromQuery]ProductionOrdersCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 工序显示
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<ProcessTable>>> ProcessTableCommand([FromQuery]ProcessTableCommand request)
        {
            return await mediator.Send(request);

        }
        /// <summary>
        /// 生产工单添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> AddProductionOrdersCommand(AddProductionOrdersCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 生产工单删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<int>> DelProductionOrdersCommand([FromQuery]DelProductionOrdersCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 生产工单修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> Handle(UpdProductionOrdersCommand request)
        {
            return await mediator.Send(request);
        }

    }
}
